package com.atguigu.aopanno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
/**
 * Title: UserProxy
 * Description: TODO
 *
 * @author gejx
 * @version V1.0
 * @date 2021-12-07
 */
@Component
@Aspect
@Order(1)
public class UserProxy {

    //抽取公共增强方法
    @Pointcut(value ="execution(* com.atguigu.aopanno.User.add(..))")
    public void pointdemo(){

    }


    //@Before前置通知add方法
    @Before("pointdemo()")
    public void before(){
        System.out.println("before...");
    }
    //后置通知
    @AfterReturning("pointdemo()")
    public void AfterReturning(){
        System.out.println("AfterReturning....");
    }

    //异常通知
    @AfterThrowing("pointdemo()")
    public void afterThrowing(){
        System.out.println("AfterThrowing....");
    }
    //环绕通知
    @Around("pointdemo()")
    public void around(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        System.out.println("....Around");
        proceedingJoinPoint.proceed();
        System.out.println("Around....");
    }
    //最终通知
    @After("pointdemo()")
    public void after(){
        System.out.println("after....");
    }
}
